import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;

public class JavaToHadoop {
    public static void main(String[] args) throws IOException {
        //获取HDFS的文件系统
        Configuration conf = new Configuration();
        //指定连接集群的主节点，以及端口号
        conf.set("fs.defaultFS","hdfs://192.168.81.151:9000");
        //如果想要操作HDFS就必须获取到HDFS提供的抽象父类的实现，FileSystem
        FileSystem fs = FileSystem.get(conf);
//        boolean b = fs.mkdirs(new Path("/test"));
//        System.out.println(b);
//        fs.copyFromLocalFile(new Path("C:\\Users\\HZH\\Desktop\\students.txt"),new Path("/test"));
        fs.copyToLocalFile(new Path("/test/students.txt"),new Path("C:\\Users\\HZH\\Desktop\\hadoop-download"));

        fs.close();


    }
}
